﻿// -----------------------------------------------------------------------
// <copyright file="ModelCache.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

using JDKD.BMCS.Model;
using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.IO;
using System.Linq;

namespace JDKD.BMCS.Business
{
        /// <summary>
        /// TODO: Update summary.
        /// </summary>
        public class ModelCache
        {
                #region 属性

                public DataContext DataContext { get; private set; }

                public List<ChannelModel> ChannelModels { get; private set; }

                public List<AreaModel> AeraModels { get; private set; }

                #endregion 属性

                #region 字段

                private Table<ChannelModel> ChannelTable;

                private Table<AreaModel> AeraTable;

                #endregion 字段

                public bool Load()
                {
                        DataContext = new DataContext(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Data\Data.sdf"));

                        ChannelTable = DataContext.GetTable<ChannelModel>();
                        ChannelModels = ChannelTable.ToList();

                        AeraTable = DataContext.GetTable<AreaModel>();
                        AeraModels = AeraTable.ToList();

                        return true;
                }
        }
}